Imports System.Data.Common


Partial Class Presentation_Control_DeactivateExecutive
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        Page.Title = "Deactivate Executive"
        If Not Page.IsPostBack Then

            UpdateExecutiveList()

        End If

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim Success As Boolean
        Dim ExecutiveToDeactivate As Executive

        ExecutiveToDeactivate = New Executive(dlExecutives.SelectedValue)
        Success = ExecutiveToDeactivate.Deactivate()

        If Success = True Then
            lblSuccess.Visible = True
            UpdateExecutiveList()
        Else
            lblSuccess.Visible = False
        End If

    End Sub

    Protected Sub UpdateExecutiveList()

        Dim Sql As String
        Dim Records As DbDataReader

        'Populate the Executives List
        dlExecutives.DataTextField = "ExecutiveName"
        dlExecutives.DataValueField = "ExecutiveID"

        Sql = "SELECT ExecutiveID, ExecutiveName FROM ExecutiveMaster" & _
            " WHERE Active = 1 ORDER BY ExecutiveName"


        Records = GenHelper.ExecuteReader(Sql, ConfigurationManager.ConnectionStrings.Item("MySqlConnString").ToString())
        dlExecutives.DataSource = Records
        dlExecutives.DataBind()
        Records.Close()

    End Sub
End Class
